package com.heima.search.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.search.pojo.HistorySearchDto;
import com.heima.search.service.ApUserSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: JW
 * @Description: TODO
 * @DateTime: 2022-02-18 14:57
 **/
@RestController
@RequestMapping("/api/v1/history")
public class ApUserSearchController {


    @Autowired
    private ApUserSearchService apUserSearchService;

    /**
     * @Author: JW
     * @Description:  TODO 历史搜索所有词条
     * @Date: 15:54 2022-02-18
     * @Param: []
     * @return: com.heima.model.common.dtos.ResponseResult
    **/
    @PostMapping("/load")
    public ResponseResult findHistory() {

        return apUserSearchService.findHistory();
    }

    /**
     * @Author: JW
     * @Description:  TODO 删除历史搜索
     * @Date: 15:55 2022-02-18
     * @Param: [historySearchDto]
     * @return: com.heima.model.common.dtos.ResponseResult
    **/
    @PostMapping("/del")
    public ResponseResult delUserSearch(@RequestBody HistorySearchDto historySearchDto) {

        return apUserSearchService.remove(historySearchDto);
    }
}
